<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>填写竞标信息</title>
<link href="./css/common.css" rel="stylesheet"  />
<link href="../../css/buttons.css" rel="stylesheet"  />
<script type="text/javascript" src="../../js/util.js"></script>
<script type="text/javascript">
function addFile(){
	var fileContainer=document.getElementById("fileContainer");
	var file=document.createElement("span");
	file.innerHTML="<input type=\"file\" name=\"attFile\" /><a href=\"#\" onclick=\"javascript:deleteFile(this)\">删除</a><br/>";
	fileContainer.appendChild(file);
}
function deleteFile(fileItem){
	if(confirm("确认删除？")){
		fileItem.parentNode.parentNode.removeChild(fileItem.parentNode);
	}
}
function checkForm(frm){
	var applyContent=frm['applyContent'];
	var attFiles=document.getElementsByName("attFile");
	if(!new FieldValidate(applyContent).tminlen(100,"申请竞标")){
		return false;
	}

	if(attFiles){//存在附件
		if(attFiles.length && attFiles.length>1){//存在自少2个附件
			for(var i=0;i<attFiles.length;i++){
				if(attFiles[i].value.trim().length<1){
					alert("请选择第"+ (i+1) +"个附件");
					attFiles[i].select();
					return false;
				}
			}
			return true;
		}
		else{//只有一个附件
			if(attFiles[0].value.trim().length<1){
				alert("请选择附件");
				attFiles[0].select();
				return false;
			}
			else
				return true;
		}
	}
	return true;
}
</script>
</head>
<body>
<form method="get" name="applyForm" onsubmit="return checkForm(this)"> 
<table width="900" align="center" border="0" cellpadding="0" cellspacing="1">
	<tr class="th">
		<td colspan="2">填写竞标信息</td>
	</tr>
	<tr>
		<td width="80">竞标申请</td>
		<td><textarea cols="80" rows="10" name="applyContent" id="applyContent"></textarea></td>
	</tr>
	<tr>
		<td>提交附件</td>
		<td>
			<div><a href="javascript:void(0)" onclick="javascript:addFile()">增加</a></div>
			<div id="fileContainer">
				<span><input type="file" name="attFile" /><a href="#" onclick="javascript:deleteFile(this)">删除</a><br/></span>
			</div>
		</td>
	</tr>
	<tr>
		<td colspan="2">
			<input type="submit" value="提交申请" />
		</td>
	</tr>
</table>
</form>
</body>
</html>